package com.ruoyi.web.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.web.domain.TNav;
import com.ruoyi.web.service.ITNavService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 导航位置分类Controller
 * 
 * @author ruoyi
 * @date 2023-10-08
 */
@RestController
@RequestMapping("/nav")
public class TNavController extends BaseController
{
    @Autowired
    private ITNavService tNavService;

    /**
     * 查询导航位置分类列表
     */
    @RequiresPermissions("web:nav:list")
    @GetMapping("/list")
    public TableDataInfo list(TNav tNav)
    {
        startPage();
        List<TNav> list = tNavService.selectTNavList(tNav);
        return getDataTable(list);
    }

    /**
     * 导出导航位置分类列表
     */
    @RequiresPermissions("web:nav:export")
    @Log(title = "导航位置分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TNav tNav)
    {
        List<TNav> list = tNavService.selectTNavList(tNav);
        ExcelUtil<TNav> util = new ExcelUtil<TNav>(TNav.class);
        util.exportExcel(response, list, "导航位置分类数据");
    }

    /**
     * 获取导航位置分类详细信息
     */
    @RequiresPermissions("web:nav:query")
    @GetMapping(value = "/{nid}")
    public AjaxResult getInfo(@PathVariable("nid") Long nid)
    {
        return success(tNavService.selectTNavByNid(nid));
    }

    /**
     * 新增导航位置分类
     */
    @RequiresPermissions("web:nav:add")
    @Log(title = "导航位置分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TNav tNav)
    {
        return toAjax(tNavService.insertTNav(tNav));
    }

    /**
     * 修改导航位置分类
     */
    @RequiresPermissions("web:nav:edit")
    @Log(title = "导航位置分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TNav tNav)
    {
        return toAjax(tNavService.updateTNav(tNav));
    }

    /**
     * 删除导航位置分类
     */
    @RequiresPermissions("web:nav:remove")
    @Log(title = "导航位置分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nids}")
    public AjaxResult remove(@PathVariable Long[] nids)
    {
        return toAjax(tNavService.deleteTNavByNids(nids));
    }
}
